<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>注册 - 拓客管理系统</title>
    <link rel="stylesheet" href="/static/css/style.css">
    <link rel="stylesheet" href="/static/css/components.css">
    <script src="https://unpkg.com/htmx.org@1.9.6"></script>
    <style>
        /* 高端注册页面专属样式 */
        .premium-auth-container {
            min-height: 100vh;
            display: flex;
            align-items: center;
            justify-content: center;
            background: linear-gradient(135deg, #1e40af 0%, #3b82f6 50%, #2563eb 100%);
            background-size: 400% 400%;
            animation: gradientShift 10s ease infinite;
            padding: 20px;
            position: relative;
            overflow: hidden;
        }
        
        @keyframes gradientShift {
            0% { background-position: 0% 50%; }
            50% { background-position: 100% 50%; }
            100% { background-position: 0% 50%; }
        }
        
        .premium-auth-container::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 1000"><defs><radialGradient id="g" cx="50%" cy="50%" r="50%"><stop offset="0%" stop-color="white" stop-opacity="0.08"/><stop offset="100%" stop-color="white" stop-opacity="0"/></radialGradient></defs><circle cx="300" cy="200" r="120" fill="url(%23g)"/><circle cx="700" cy="400" r="180" fill="url(%23g)"/><circle cx="200" cy="600" r="100" fill="url(%23g)"/><circle cx="800" cy="700" r="90" fill="url(%23g)"/><circle cx="500" cy="100" r="60" fill="url(%23g)"/></svg>');
            pointer-events: none;
            animation: float 25s ease-in-out infinite;
        }
        
        @keyframes float {
            0%, 100% { transform: translateY(0px) rotate(0deg); }
            25% { transform: translateY(-15px) rotate(0.5deg); }
            50% { transform: translateY(-25px) rotate(-0.5deg); }
            75% { transform: translateY(-10px) rotate(0.3deg); }
        }
        
        .premium-auth-card {
            background: rgba(255, 255, 255, 0.12);
            backdrop-filter: blur(30px);
            border: 1px solid rgba(255, 255, 255, 0.25);
            padding: 36px 28px;
            border-radius: 24px;
            box-shadow: 
                0 40px 80px rgba(0, 0, 0, 0.25),
                0 20px 40px rgba(0, 0, 0, 0.15),
                inset 0 1px 0 rgba(255, 255, 255, 0.2),
                inset 0 -1px 0 rgba(0, 0, 0, 0.1);
            width: 100%;
            max-width: 420px;
            margin: 0 20px;
            position: relative;
            z-index: 1;
            animation: cardFloat 8s ease-in-out infinite;
            display: flex;
            flex-direction: column;
            align-items: center;
        }
        
        @keyframes cardFloat {
            0%, 100% { transform: translateY(0px) scale(1); }
            33% { transform: translateY(-8px) scale(1.01); }
            66% { transform: translateY(-5px) scale(1.005); }
        }
        
        .premium-auth-card::before {
            content: '';
            position: absolute;
            top: -3px;
            left: -3px;
            right: -3px;
            bottom: -3px;
            background: linear-gradient(45deg, 
                rgba(255, 255, 255, 0.2), 
                rgba(255, 255, 255, 0.05), 
                rgba(255, 255, 255, 0.15),
                rgba(255, 255, 255, 0.1));
            background-size: 400% 400%;
            animation: gradientBorder 6s ease infinite;
            border-radius: 35px;
            z-index: -1;
        }
        
        @keyframes gradientBorder {
            0%, 100% { background-position: 0% 50%; }
            50% { background-position: 100% 50%; }
        }
        
        .premium-title {
            text-align: center;
            margin-bottom: 24px;
            position: relative;
            width: 100%;
        }
        
        .premium-title h1 {
            color: white;
            font-size: 26px;
            font-weight: 800;
            letter-spacing: -0.02em;
            margin-bottom: 8px;
            text-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
            background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 70%, #e9ecef 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }
        
        .premium-title p {
            color: rgba(255, 255, 255, 0.85);
            font-size: 13px;
            font-weight: 400;
            letter-spacing: 0.8px;
            text-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
        }
        
        .premium-form-group {
            margin-bottom: 18px;
            position: relative;
            width: 100%;
            max-width: 320px;
        }
        
        .premium-form-control {
            width: 100%;
            padding: 15px 18px;
            border: 2px solid rgba(255, 255, 255, 0.2);
            border-radius: 16px;
            font-size: 14px;
            font-weight: 500;
            background: rgba(255, 255, 255, 0.1);
            backdrop-filter: blur(15px);
            color: white;
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            box-shadow: 
                inset 0 2px 4px rgba(0, 0, 0, 0.1),
                0 1px 2px rgba(255, 255, 255, 0.1);
            box-sizing: border-box;
        }
        
        .premium-form-control::placeholder {
            color: rgba(255, 255, 255, 0.65);
            font-weight: 400;
        }
        
        .premium-form-control:focus {
            outline: none;
            border-color: rgba(255, 255, 255, 0.45);
            background: rgba(255, 255, 255, 0.18);
            box-shadow: 
                inset 0 2px 4px rgba(0, 0, 0, 0.1),
                0 0 0 4px rgba(255, 255, 255, 0.15),
                0 8px 20px rgba(0, 0, 0, 0.15);
            transform: translateY(-2px);
        }
        
        .premium-btn {
            width: 100%;
            max-width: 320px;
            padding: 16px 20px;
            border: none;
            border-radius: 16px;
            font-size: 16px;
            font-weight: 700;
            cursor: pointer;
            position: relative;
            overflow: hidden;
            background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
            color: #333;
            box-shadow: 
                0 8px 16px rgba(0, 0, 0, 0.2),
                0 4px 8px rgba(0, 0, 0, 0.1);
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            margin-bottom: 20px;
            box-sizing: border-box;
            align-self: center;
        }
        
        .premium-btn::before {
            content: '';
            position: absolute;
            top: 0;
            left: -100%;
            width: 100%;
            height: 100%;
            background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
            transition: left 0.6s;
        }
        
        .premium-btn:hover {
            transform: translateY(-3px);
            box-shadow: 
                0 12px 24px rgba(0, 0, 0, 0.25),
                0 6px 12px rgba(0, 0, 0, 0.15);
        }
        
        .premium-btn:hover::before {
            left: 100%;
        }
        
        .premium-btn:active {
            transform: translateY(-1px);
        }
        
        .premium-link {
            text-align: center;
            margin-top: 20px;
            width: 100%;
        }
        
        .premium-link p {
            color: rgba(255, 255, 255, 0.8);
            font-size: 14px;
            margin: 0;
        }
        
        .premium-link a {
            color: #ffffff;
            text-decoration: none;
            font-weight: 600;
            text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
            border-bottom: 1px solid rgba(255, 255, 255, 0.4);
            transition: all 0.3s ease;
        }
        
        .premium-link a:hover {
            color: #ffffff;
            border-bottom-color: white;
            text-shadow: 0 2px 8px rgba(255, 255, 255, 0.4);
            transform: translateY(-1px);
        }
        
        .loading-overlay {
            display: none;
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(255, 255, 255, 0.1);
            backdrop-filter: blur(2px);
            border-radius: 16px;
            align-items: center;
            justify-content: center;
        }
        
        .loading-spinner {
            width: 24px;
            height: 24px;
            border: 2px solid rgba(255, 255, 255, 0.3);
            border-radius: 50%;
            border-top-color: white;
            animation: spin 1s linear infinite;
        }
        
        @keyframes spin {
            to { transform: rotate(360deg); }
        }
        
        /* 输入验证样式 */
        .form-validation {
            font-size: 12px;
            color: rgba(255, 100, 100, 0.9);
            margin-top: 6px;
            text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
        }
        
        .premium-form-control.error {
            border-color: rgba(255, 100, 100, 0.6);
            background: rgba(255, 100, 100, 0.1);
        }
        
        /* 响应式设计 */
        @media (max-width: 768px) {
            .premium-auth-card {
                padding: 28px 20px;
                max-width: 360px;
                margin: 0 16px;
                border-radius: 20px;
            }
            
            .premium-title h1 {
                font-size: 22px;
            }
            
            .premium-title p {
                font-size: 12px;
            }
            
            .premium-form-control {
                padding: 13px 16px;
                font-size: 13px;
                border-radius: 14px;
            }
            
            .premium-btn {
                padding: 14px 18px;
                font-size: 15px;
                border-radius: 14px;
            }
            
            .form-validation {
                font-size: 11px;
            }
        }
        
        @media (max-width: 480px) {
            .premium-auth-container {
                padding: 16px;
            }
            
            .premium-auth-card {
                padding: 24px 16px;
                margin: 0 8px;
                max-width: 320px;
            }
            
            .premium-form-group {
                max-width: 260px;
            }
            
            .premium-btn {
                max-width: 260px;
            }
            
            .premium-title {
                margin-bottom: 20px;
            }
            
            .premium-title h1 {
                font-size: 20px;
            }
            
            .premium-form-group {
                margin-bottom: 16px;
                max-width: 280px;
            }
            
            .premium-btn {
                max-width: 280px;
            }
        }
    </style>
</head>
<body>
    <div class="premium-auth-container">
        <div class="premium-auth-card">
            <div class="premium-title">
                <h1>创建账户</h1>
                <p>加入拓客管理系统，开启智能销售之旅</p>
            </div>
            
            <form id="register-form" style="width: 100%; display: flex; flex-direction: column; align-items: center; margin: 0; padding: 0;">
                  
                <div class="premium-form-group">
                    <input type="text" 
                           id="username" 
                           name="username" 
                           class="premium-form-control" 
                           placeholder="请输入用户名" 
                           required>
                    <div class="form-validation" id="username-validation"></div>
                </div>
                
                <div class="premium-form-group">
                    <input type="email" 
                           id="email" 
                           name="email" 
                           class="premium-form-control" 
                           placeholder="请输入邮箱地址" 
                           required>
                    <div class="form-validation" id="email-validation"></div>
                </div>
                
                <div class="premium-form-group">
                    <input type="password" 
                           id="password" 
                           name="password" 
                           class="premium-form-control" 
                           placeholder="请输入密码（至少6位）" 
                           minlength="6"
                           required>
                    <div class="form-validation" id="password-validation"></div>
                </div>
                
                <div class="premium-form-group">
                    <input type="password" 
                           id="confirm_password" 
                           name="confirm_password" 
                           class="premium-form-control" 
                           placeholder="请再次输入密码" 
                           required>
                    <div class="form-validation" id="confirm-validation"></div>
                </div>
                
                <div style="width: 100%; display: flex; justify-content: center; margin-top: 8px;">
                    <button type="submit" class="premium-btn">
                        <span class="btn-text">创建账户</span>
                        <div class="loading-overlay">
                            <div class="loading-spinner"></div>
                        </div>
                    </button>
                </div>
            </form>
            
            <div class="premium-link">
                <p>已有账户？<a href="login.html">立即登录</a></p>
            </div>
        </div>
    </div>

    <script src="/static/js/app.js"></script>
    
    <script>
        // 实时验证功能
        const validators = {
            username: (value) => {
                if (value.length < 3) return '用户名至少需要3个字符';
                if (!/^[a-zA-Z0-9_\u4e00-\u9fa5]+$/.test(value)) return '用户名只能包含字母、数字、下划线和中文';
                return null;
            },
            email: (value) => {
                if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)) return '请输入正确的邮箱地址';
                return null;
            },
            password: (value) => {
                if (value.length < 6) return '密码至少需要6个字符';
                if (!/(?=.*[a-zA-Z])(?=.*\d)/.test(value)) return '密码应包含字母和数字';
                return null;
            },
            confirm_password: (value) => {
                const password = document.getElementById('password').value;
                if (value !== password) return '两次输入的密码不一致';
                return null;
            }
        };
        
        // 绑定验证事件
        Object.keys(validators).forEach(field => {
            const input = document.getElementById(field);
            const validation = document.getElementById(field.replace('_', '-') + '-validation');
            
            input.addEventListener('input', function() {
                const error = validators[field](this.value);
                if (error) {
                    this.classList.add('error');
                    validation.textContent = error;
                } else {
                    this.classList.remove('error');
                    validation.textContent = '';
                }
            });
            
            input.addEventListener('focus', function() {
                this.parentElement.style.transform = 'scale(1.02)';
            });
            
            input.addEventListener('blur', function() {
                this.parentElement.style.transform = 'scale(1)';
            });
        });

        // 注册表单处理
        document.getElementById('register-form').addEventListener('submit', function(e) {
            e.preventDefault();
            
            // 验证所有字段
            let hasError = false;
            Object.keys(validators).forEach(field => {
                const input = document.getElementById(field);
                const error = validators[field](input.value);
                if (error) {
                    hasError = true;
                    input.classList.add('error');
                    document.getElementById(field.replace('_', '-') + '-validation').textContent = error;
                }
            });
            
            if (hasError) {
                return;
            }
            
            const loading = this.querySelector('.loading-overlay');
            const btnText = this.querySelector('.btn-text');
            loading.style.display = 'flex';
            btnText.style.opacity = '0';
            
            // 模拟注册延迟
            setTimeout(() => {
                loading.style.display = 'none';
                btnText.style.opacity = '1';
                
                // 模拟注册成功
                showToast('注册成功！请登录');
                setTimeout(() => {
                    window.location.href = 'login.html';
                }, 1500);
            }, 1500);
        });
        
        // Toast通知函数
        function showToast(message, type = 'success') {
            const toast = document.createElement('div');
            toast.textContent = message;
            toast.style.cssText = `
                position: fixed;
                top: 20px;
                right: 20px;
                background: ${type === 'error' ? '#ef4444' : '#3b82f6'};
                color: white;
                padding: 12px 20px;
                border-radius: 12px;
                font-size: 14px;
                font-weight: 500;
                z-index: 10000;
                box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
                transform: translateX(100%);
                transition: transform 0.3s ease;
            `;
            
            document.body.appendChild(toast);
            
            setTimeout(() => {
                toast.style.transform = 'translateX(0)';
            }, 100);
            
            setTimeout(() => {
                toast.style.transform = 'translateX(100%)';
                setTimeout(() => {
                    if (document.body.contains(toast)) {
                        document.body.removeChild(toast);
                    }
                }, 300);
            }, 3000);
        }
    </script>
</body>
</html>